<layout name="Iflayout"/>
<script type="text/javascript" src="__PUBLIC__/js/jquery.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.all.js"></script>
<style>
    #content1{
        width: 1020px;
        height: 400px;
    }
</style>
<script type="text/javascript">
    $(function () {
        //缩略图上传
        var litpic_tip = $(".litpic_tip");
        var btn = $(".up-picture-btn span");
        $("#fileupload").wrap("<form id='myupload' action=\"{:U('Article/upload')}\" method='post' enctype='multipart/form-data'></form>");
        $("#fileupload").change(function(){
            if($("#fileupload").val() == "") return;
            $("#myupload").ajaxSubmit({
                dataType:  'json',
                beforeSend: function() {
                    $('#litpic_show').empty();
                    btn.html("上传中...");
                },
                success: function(data) {
                    if(data.state == 'SUCCESS'){
                        var fileSize = parseFloat(data.info[0].size/1024).toFixed(2);
                        litpic_tip.html(""+ data.info[0].name +" 上传成功("+ fileSize +"k)");
                        var img = data.info[0].url;//原图
                        var timg = data.info[0].turl;//缩略图
                        $('#litpic_show').html("<img src='"+timg+"' width='120'>");
                        $("#litpic").val(timg);
                    }else {
                        litpic_tip.html(data.state);
                    }
                    btn.html("添加图片");

                },
                error:function(xhr){
                    btn.html("上传失败");
                    litpic_tip.html(xhr);
                }
            });
        });

        $('#CK_JumpUrl').click(function(){
            if($(this).prop('checked')) {
                $('#JumpUrlDiv').show();

            }else {
                $('#JumpUrlDiv').hide();
            }

        });

    });
    $(function () {
        $('#BrowerPicture').click(function(){
            layer.open({
                type: 2,
                title: 'XYHCMS',
                shadeClose: true,
                shade: 0.5,
                area: ['670px', '350px'],
                content: "{:U('Article/tp')}"
            });
        });
    });
    function selectPicture(sfile) {
        layer.msg('选择文件成功')
        $("#litpic").val(sfile);
        $('#litpic_show').html("<img src='"+sfile+"' width='120'>");
    }

</script>
<div class="xyh-content">

    <div class="row">
        <div class="col-lg-12">
            <h3 class="page-header"><em class="glyphicon glyphicon-cloud-upload"></em>
                添加文章
            </h3>
        </div>
    </div>


    <div class="row">
        <div class="col-lg-12">
            <form method='post' class="form-horizontal" id="form_do" name="form_do" action="{:U('Article/add')}">

                <div class="form-group">
                    <label for="inputTtitle" class="col-sm-2 control-label">标题</label>
                    <div class="col-sm-9">
                        <input type="text" name="title" id="inputTtitle" class="form-control" placeholder="标题" required="required" />
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputShorttitle" class="col-sm-2 control-label">副标题</label>
                    <div class="col-sm-9">
                        <input type="text" name="shorttitle" id="inputShorttitle" class="form-control" placeholder="副标题" />
                    </div>
                </div>

                <div class="form-group">
                    <label for="inputColor" class="col-sm-2 control-label">标题颜色</label>
                    <div class="col-sm-5">
                        <input type="text" name="color" id="inputColor" class="iColorPicker" placeholder="标题颜色" />
                    </div>
                </div>

                <div class="form-group">
                    <label for="inputColor" class="col-sm-2 control-label">自定义属性</label>
                    <div class="col-sm-9">
                        <label class="checkbox-inline"><input type='checkbox' name='flags[]' value='1'  /> 图片</label>
                        <label class="checkbox-inline"><input type='checkbox' name='flags[]' value='2'  /> 头条</label>
                        <label class="checkbox-inline"><input type='checkbox' name='flags[]' value='4'  /> 推荐</label>
                        <label class="checkbox-inline"><input type='checkbox' name='flags[]' value='8'  /> 特荐</label>
                        <label class="checkbox-inline"><input type='checkbox' name='flags[]' value='16'  /> 幻灯</label>
                        <label class="checkbox-inline"><input type='checkbox' name='flags[]' value='32' id="CK_JumpUrl" /> 跳转</label>
                        <label class="checkbox-inline"><input type='checkbox' name='flags[]' value='64'  /> 其他</label>
                    </div>
                </div>

                <div class="form-group" id="JumpUrlDiv" style="display:none;">
                    <label for="inputJumpurl" class="col-sm-2 control-label">跳转网址</label>
                    <div class="col-sm-9">
                        <input type="text" name="jumpurl" id="inputJumpurl" class="form-control" placeholder="跳转网址" />
                    </div>
                </div>

                <div class="form-group">
                    <label for="inputProName" class="col-sm-2 control-label">所属栏目</label>
                    <div class="col-sm-9">
                        <select name="cid" class="form-control">
                            <option value="2" selected="selected">新闻中心</option><option value="3" >———公司新闻</option><option value="4" >———行业新闻</option>
                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <label for="litpic" class="col-sm-2 control-label">缩略图</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="litpic" id="litpic"  value="" placeholder="缩略图地址" />
                    </div>
                    <div class="col-sm-5">
                        <button class="btn btn-primary" type="button" id="BrowerPicture"><em class="glyphicon glyphicon-plus-sign"></em> 选择站内图片</button>
                        <div class="btn btn-success up-picture-btn">
                            <span><em class="glyphicon glyphicon-plus-sign"></em>添加图片</span>
                            <input id="fileupload" type="file" name="mypic">
                        </div>
                    </div>
                </div>


                <div class="form-group">
                    <label for="" class="col-sm-2 control-label"></label>
                    <div class="col-sm-9">
                        <div class="litpic_tip"></div>
                        <div id="litpic_show"> </div>
                    </div>
                </div>

                <div class="form-group">
                    <label for="inputKeywords" class="col-sm-2 control-label">关键词</label>
                    <div class="col-sm-9">
                        <input type="text" name="keywords" id="inputKeywords" class="form-control" value="" placeholder="多关键词之间用“,”隔开" />
                    </div>
                </div>

                <div class="form-group">
                    <label for="inputDescription" class="col-sm-2 control-label">摘要</label>
                    <div class="col-sm-9">
                        <textarea name="description" id="inputDescription" class="form-control"></textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputAuthor" class="col-sm-2 control-label">作者</label>
                    <div class="col-sm-9">
                        <input type="text" name="author" id="inputAuthor" class="form-control" value="" placeholder="作者" />
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputCopyfrom" class="col-sm-2 control-label">来源</label>
                    <div class="col-sm-9">
                        <input type="text" name="copyfrom" id="inputCopyfrom" class="form-control" value="" placeholder="来源" />
                    </div>
                </div>

                <div class="form-group">
                    <label for="inputContent" class="col-sm-2 control-label">内容</label>
                    <div class="col-sm-9">
                        <textarea name="content" id="inputContent" style="height: 370px;"></textarea>
                    </div>
                </div>

                <div class="form-group">
                    <label for="inputPublishtime" class="col-sm-2 control-label">发布时间</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="publishtime" id="inputPublishtime" value="2017-08-28 11:07:05">
                        <script type="text/javascript">
                            Calendar.setup({
                                weekNumbers: true,
                                inputField : "inputPublishtime",
                                trigger    : "inputPublishtime",
                                dateFormat: "%Y-%m-%d %H:%M:%S",
                                showTime: true,
                                minuteStep: 1,
                                onSelect   : function() {this.hide();}
                            });
                        </script>
                    </div>
                </div>


                <div class="form-group">
                    <label for="inputName" class="col-sm-2 control-label">评论</label>
                    <div class="col-sm-9">
                        <label class="radio-inline">
                            <input type="radio" name="commentflag" value="1" checked="checked" />允许
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="commentflag" value="0" />禁止
                        </label>
                    </div>
                </div>

                <div class="row margin-botton-large">
                    <div class="col-sm-offset-2 col-sm-9">
                        <input type="hidden" name="pid" value="2" />
                        <div class="btn-group">
                            <button type="submit" class="btn btn-primary"> <i class="glyphicon glyphicon-saved"></i>
                                保存
                            </button>
                            <button type="button" onclick="goUrl('/xyhai.php?s=/Article/index')" class="btn btn-default"> <i class="glyphicon glyphicon-chevron-left"></i>
                                返回
                            </button>
                        </div>
                    </div>
                </div>
            </form>

        </div>
    </div>
</div>


<script type="text/javascript">

    var ue = UE.getEditor('inputContent');
    ue.ready(function() {
        ue.setHeight(250);
        //设置编辑器的内容
        // ue.setContent('hello');
        // //获取html内容，返回: <p>hello</p>
        // var html = ue.getContent();
        //获取纯文本内容，返回: hello
        // var txt = ue.getContentTxt();
    });

</script>
